package com.guoxianwei.scm.web.ajaxresult;

import java.io.Serializable;

import com.guoxianwei.util.GSONUtils;

public class AjaxResult implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -718424172389862492L;

	private boolean isError;
	private String message;
	private Object date;

	public boolean isError() {
		return isError;
	}

	public void isError(boolean isError) {
		this.isError = isError;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getDate() {
		return date;
	}

	public void setDate(Object date) {
		this.date = date;
	}

	public AjaxResult() {
	}

	public AjaxResult(boolean isError) {
		this.isError = isError;
	}
	public AjaxResult(Object date) {
		this.isError = false;
		this.date = date;
	}
	public AjaxResult(Object date, String message) {
		this.isError = false;
		this.date = date;
		this.message = message;
	}

	public AjaxResult(boolean isError, String message) {
		this.isError = isError;
		this.message = message;
		this.date = null;
	}

	public AjaxResult(boolean isError, Object date, String message) {
		this.isError = isError;
		this.date = date;
		this.message = message;
	}

	public static AjaxResult error() {
		return new AjaxResult(true);
	}

	public static AjaxResult error(String message) {
		return new AjaxResult(true, message);
	}

	public static AjaxResult success() {
		return new AjaxResult(false);
	}

	public static AjaxResult success(String message) {
		return new AjaxResult(false, message);
	}
	public static AjaxResult success(Object date) {
		return new AjaxResult(date);
	}
	public static AjaxResult success(Object date, String message) {
		return new AjaxResult(false, message);
	}

	public String toString() {
		return GSONUtils.toJson(this, false);
	}
}
